package tools;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

public class GameElement {
	
	protected double xVel;
	protected double yVel;
	protected BufferedImage image;
	protected Rect me;
	protected int code;
	//protected int life;
	protected boolean die;
	
	public GameElement() {
		this(null, 0, 0, 0, 0, 0, 0, -1);
		code = -1;
		//life = 0;
		die = false;
	}
	public GameElement(BufferedImage img, Rect r, double xv, double yv, int id)
	{
		this(img, r.x, r.y, r.w, r.h, xv, yv, id);
	}
	public GameElement(BufferedImage img, double x, double y, double w, double h, double xv, double yv, int id){
		xVel = xv;
		yVel = yv;
		me  = new Rect(x, y, w, h);
		image = img;
		code = id;
		//life = 0;
		die = false;
	}

	public double getXVel() {
		return xVel;
	}
	public void setXVel(double velocidade) {
		this.xVel = velocidade;
	}

	public double getYVel() {
		return yVel;
	}
	public void setYVel(double velocidade) {
		this.yVel = velocidade;
	}
	
	public Rect getRect()
	{
		return me;
	}
	
	public void setID(int id)
	{
		code = id;
	}
	public int getID() {
		return code;
	}
	
	public void move()
	{
		me.x += xVel;
		me.y += yVel;
		//life++;
		//if(life >= 300) die = true;
	}
	
	public boolean timeOut()
	{
		return die;
	}
	
	public BufferedImage getImage()
	{
		return image;
	}
	
	public void draw(Graphics g, Rect cam)
	{
		g.drawImage(image, (int)(me.x - cam.x), (int)(me.y - cam.y), null);
	}
}
